#pragma once
#include "HashTable.h"
#include <iostream>
using namespace std;
namespace nineone
{
	template<class K, class Hash = HashFunc<K>>
	class unordered_set
	{
		struct KeyOfSet
		{
			const K& operator()(const K& rhs) const
			{
				return rhs;
			}
		};
	public:
		typedef typename HashTable<K, K, KeyOfSet, Hash>::Iterator iterator;
		typedef typename HashTable<K, K, KeyOfSet, Hash>::ConstIterator const_iterator;
		iterator begin()
		{
			return _ht.begin();
		}

		iterator end()
		{
			return _ht.end();
		}

		const_iterator begin() const
		{
			return _ht.begin();
		}

		const_iterator end() const
		{
			return _ht.end();
		}
		pair<iterator, bool> insert(const K& key)
		{
			return _ht.Insert(key);
		}
		iterator find(const K& key)
		{
			return _ht.Find(key);
		}
		bool erase(const K& key)
		{
			return _ht.Erase(key);
		}
	private:
		HashTable<K, K, KeyOfSet, Hash> _ht;
	};

	void Test_unordered_set()
	{
		unordered_set<int> st;
		st.insert(1);
		st.insert(2);
		st.insert(3);
		st.insert(11);
		st.insert(22);
		st.insert(33);
		unordered_set<int>::iterator it = st.begin();
		while (it != st.end())
		{
			cout << *it << endl;
			++it;
		}
	}
}